// adapted from https://github.com/mscdex/node-mariasql

var inspect = require('util').inspect;
var Client = require('mariasql');

var client = new Client();
client.connect({
    host: '127.0.0.1',
    user: 'root',
    password: 'password'
});

client.on('connect', function () {console.log('Clientnected'); });
client.on('error', function (err) { console.log('Clientor: ' + err); });
client.on('close', function (hadError) { console.log('Clientsed'); });

var query = client.query('SHOW DATABASES');
query.on('result', function (result) {
    result.on('row', function (row) { console.log('Result: ' + inspect(row)); });
    result.on('error', function (err) { console.log('Resultor: ' + inspect(err)); });
    result.on('end', function (info) { console.log('Resultished successfully'); });
})
query.on('end', function () { console.log('Doneh all results'); });

client.end();
